/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

/* eslint-disable @typescript-eslint/no-shadow */
import React, { useState } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { Tabs } from 'antd';
import YzInfoVerifyTable from '@/components/_pages/OperatorManagement/YzInfoVerify';
import YzInfoVerifyDetail from '@/components/_pages/OperatorManagement/YzInfoVerify/detail';
import RedPoint from '@/components/_pages/red-point';

/**
 * 经营信息审核
 *  */
const YzInfoVerify: React.FC = () => {
  const [activeKey, setActiveKey] = useState<number>(1);
  const [id, setId] = useState('');

  const tabList = [
    {
      tab: <RedPoint type='0'>待审核</RedPoint>,
      key: 1,
    },
    {
      tab: '已通过',
      key: 3,
    },
    {
      tab: '未通过',
      key: 2,
    },
  ];

  const handleTabChange = (key: string) => setActiveKey(Number(key));

  const checkDetail = (id: string) => {
    setId(id);
  };

  return (
    <PageContainer>
      {id ? (
        <YzInfoVerifyDetail type={activeKey} id={id} goBack={checkDetail} />
      ) : (
        <Tabs onChange={handleTabChange} activeKey={`${activeKey}`}>
          {tabList.map((item) => (
            <Tabs.TabPane tab={item.tab} key={item.key}>
              <YzInfoVerifyTable type={item.key} activeKey={activeKey} checkDetail={checkDetail} />
            </Tabs.TabPane>
          ))}
        </Tabs>
      )}
    </PageContainer>
  );
};

export default YzInfoVerify;
